#include "lib/optimal_binary_tree.h"

#include <iostream>
#include <vector>

#define ARRAY_SIZE(arr) (sizeof(arr) / sizeof(arr[0]))

int main(int argc, char** argv) {
    double probabilities[] = { 0.15, 0.10, 0.05, 0.10, 0.20 };
    double missProbabilities[] = { 0.05, 0.10, 0.05, 0.05, 0.05, 0.10 };
    int keys[] = { 1, 2, 3, 4, 5 };
    int values[] = { 1, 2, 3, 4, 5 };

    TBinaryTree<int, int> tree = BuildOptimalBinaryTree(ARRAY_SIZE(probabilities), keys, values, probabilities, missProbabilities, &std::cerr);
    for (int i = -3; i < 8; ++i) {
        const int* found = tree.Find(i);
        std::cerr << i << " -> ";
        if (found)
            std::cerr << *found << std::endl;
        else
            std::cerr << "not found" << std::endl;
    }
    return 0;
}
